package vsy.buzzwordbingo.client;

import java.io.IOException;
import java.util.List;

import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import org.springframework.web.client.RestTemplate;

import vsy.buzzwordbingo.model.impl.GameBuilder;
import vsy.buzzwordbingo.model.impl.PlayerBuilder;

public class PlayerList extends Thread {
	public void run(){
		RestTemplate rt = GameClient.userAuthenticate();
		String players = rt.getForObject("http://"+GameClient.path+":8080/buzzwordbingo/rest/boards", String.class);
		
		ObjectMapper mapper = new ObjectMapper();
		List<PlayerBuilder> player;
		try {
			player = mapper.readValue(players, new TypeReference<List<PlayerBuilder>>() { });
			for (PlayerBuilder p : player ){
				
			}
		} catch (JsonParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (JsonMappingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}
}